// source --> /wp-content/themes/nrWpOOP-child/assets/js/privacy-v2.js window.NrCookieHandler = { config: { withbackground: false, primarycolor: '#1E513E', cookietypes: { essential: 'essential', statistics: 'statistics', marketing: 'marketing', externmedia: 'externmedia' } }, text: { de: { title: 'Datenschutzeinstellungen', body: 'Wir nutzen Cookies auf unserer Website. Einige von ihnen sind essenziell, während
andere uns helfen, diese Website und Ihre Erfahrung zu verbessern.', selectors: { essential: 'Essenziell', statistics: 'Statistiken', marketing: 'Marketing', externmedia: 'Externe Medien' }, buttons: { acceptall: 'Alle akzeptieren', acceptselection: 'Auswahl akzeptieren', acceptessential: 'Nur essenzielle Cookies akzeptieren' }, links: { privacypolicy: { href: '/datenschutz', name: 'Datenschutzerklärung' }, imprint: { href: '/impressum', name: 'Impressum' } } } }, lang: function (language, textselector) { textselector = textselector.split('.'); var res = this.text[language]; for (var i = 0; i < textselector.length; i++) { res = res[textselector[i]]; } return res; }, queue: function (cookieType, queuedScript, mimeType) { document.addEventListener("DOMContentLoaded", function () { if (NrCookieHandler.isCookieTypeAllowed(cookieType)) { NrCookieHandler.writeScript(queuedScript, mimeType); return; } window.addEventListener('NrCookieHandler', function (event) { if (event.detail.name === cookieType && event.detail.status === true) { NrCookieHandler.writeScript(queuedScript, mimeType); } }); }); }, writeScript(script, mimeType) { if (this.isCallable(script)) { script(); return; } if (script.indexOf('http') !== 0) { eval(script); return; } var scriptHolder = document.querySelector('#nrPrivacyScriptsHolder'); var scriptTag = document.createElement('script'); scriptTag.type = mimeType ? mimeType : 'text/javascript'; scriptTag.charset = 'utf-8'; // scriptTag.id = 'testing'; scriptTag.defer = true; scriptTag.async = true; scriptTag.src = script; scriptHolder.appendChild(scriptTag); }, isCallable: function (functionToCheck) { return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]'; }, storeUserSelection: function (cookieSettings) { localStorage.setItem('cookies_allowed_' + cookieSettings.name, cookieSettings.status ? 'true' : 'false'); if (cookieSettings.status) { window.dispatchEvent( new CustomEvent('NrCookieHandler', {detail: cookieSettings}) ); } }, acceptall: function () { for (var prop in this.config.cookietypes) { if (Object.prototype.hasOwnProperty.call(this.config.cookietypes, prop)) { this.storeUserSelection({ name: prop, status: true }); } } this.hide(); }, acceptselection: function () { var selectors = document.querySelectorAll('.nr-privacy-modal-box-v2 .inner .selectors .selector input'); for (var i = 0; i < selectors.length; i++) { if (selectors[i].checked) { this.storeUserSelection({ name: selectors[i].name, status: true }); } } this.hide(); }, acceptessential: function () { this.storeUserSelection({ name: this.config.cookietypes.essential, status: true }); this.hide(); }, isCookieTypeAllowed: function (name) { return localStorage.getItem('cookies_allowed_' + name) === 'true'; }, init: function () { var nrPrivacyScriptsHolder = document.createElement('div'); nrPrivacyScriptsHolder.id = 'nrPrivacyScriptsHolder'; document.body.appendChild(nrPrivacyScriptsHolder); if (!this.isLegalPage() && !this.isCookieTypeAllowed(this.config.cookietypes.essential)) { this.show(); } }, show: function () { document.querySelector('.nr-privacy-modal-box-v2').classList.remove('hidden'); }, hide: function () { document.querySelector('.nr-privacy-modal-box-v2').classList.add('hidden'); }, isLegalPage: function () { var languages = Object.values(this.text); for (var i = 0; i < languages.length; i++) { var links = Object.values(languages[i].links); for (var j = 0; j < links.length; j++) { if (location.pathname.indexOf(links[j].href) === 0) { return true; } if (location.href.indexOf(links[j].href) === 0) { return true; } } } return false; } }; document.addEventListener("DOMContentLoaded", function () { var language = 'de'; var modalMarkup = '' + '' + '' + ''; var nrPrivacyModal = document.createElement('div'); nrPrivacyModal.innerHTML = modalMarkup; document.body.appendChild(nrPrivacyModal); NrCookieHandler.init(); }); document.addEventListener('DOMContentLoaded', function () { var NrCookieHandlerOpener = document.querySelector('.opencookiepanel'); if (NrCookieHandlerOpener) { NrCookieHandlerOpener.addEventListener('click', function (e) { e.preventDefault(); NrCookieHandler.show(); }); } }); document.addEventListener('opencookiepanel', e => { NrCookieHandler.show(); }, false); // NrCookieHandler.queue('essential', 'console.log("here we go");'); // NrCookieHandler.queue('essential', 'https://www.web-pflege.com/wp-content/themes/nrWpOOP-child/js/privacy-v2.js'); // NrCookieHandler.queue('essential', function () { // console.log("here we go"); // });